<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>hrtfer</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="DeprecatedTop.html" title="Deprecated Orchestra Opcodes and GEN Routines" />
    <link rel="prev" href="clock.html" title="clock" />
    <link rel="next" href="ibetarand.html" title="ibetarand" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">hrtfer</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="clock.html">Prev</a> </td>
          <th width="60%" align="center">Deprecated Orchestra Opcodes and GEN Routines</th>
          <td width="20%" align="right"> <a accesskey="n" href="ibetarand.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="hrtfer"></a>
      <div class="titlepage"></div>
      <a id="IndexHrtfer" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">hrtfer</span>
        </h2>
        <p>hrtfer — 
      Creates 3D audio for two speakers.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp219527808"></a>
        <h2>Description</h2>
        <p>
      Output is binaural (headphone) 3D audio.
    </p>
        <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
          <table border="0" summary="Note">
            <tr>
              <td rowspan="2" align="center" valign="top" width="25">
                <img alt="[Note]" src="images/note.png" />
              </td>
              <th align="left">Note</th>
            </tr>
            <tr>
              <td align="left" valign="top">This opcode is deprecated; use hrtfstat or similar opcode instead</td>
            </tr>
          </table>
        </div>
      </div>
      <div class="refsect1">
        <a id="idp219529344"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">aleft, aright <span class="command"><strong>hrtfer</strong></span> asig, kaz, kelev, <span class="quote">“<span class="quote">HRTFcompact</span>”</span></pre>
      </div>
      <div class="refsect1">
        <a id="idp219531808"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>kAz</em></span> -- azimuth value in degrees. Positive values represent position on the right, negative values are positions on the left.
    </p>
        <p>
      <span class="emphasis"><em>kElev</em></span> -- elevation value in degrees. Positive values represent position above horizontal, negative values are positions under horizontal.
    </p>
        <p>
      At present, the only file which can be used with <span class="emphasis"><em>hrtfer</em></span> is <a class="ulink" href="examples/HRTFcompact" target="_top"><em class="citetitle">HRTFcompact</em></a>. It must be passed to the opcode as the last argument within quotes as shown above.
    </p>
        <p>
      HRTFcompact may also be obtained via anonymous ftp from: <a class="ulink" href="ftp://ftp.cs.bath.ac.uk/pub/dream/utilities/Analysis/HRTFcompact" target="_top"><em class="citetitle">ftp://ftp.cs.bath.ac.uk/pub/dream/utilities/Analysis/HRTFcompact</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp219537696"></a>
        <h2>Performance</h2>
        <p>
      These unit generators place a mono input signal in a virtual 3D space around the listener by convolving the input with the appropriate HRTF data specified by the opcode's azimuth and elevation values. <span class="emphasis"><em>hrtfer</em></span> allows these values to be k-values, allowing for dynamic spatialization. <span class="emphasis"><em>hrtfer</em></span> can only place the input at the requested position because the HRTF is loaded in at i-time (remember that currently, CSound has a limit of 20 files it can hold in memory, otherwise it causes a segmentation fault). The output will need to be scaled either by using <a class="link" href="balance.html" title="balance"><em class="citetitle">balance</em></a> or by multiplying the output by some scaling constant.
    </p>
        <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
          <table border="0" summary="Note: Note">
            <tr>
              <td rowspan="2" align="center" valign="top" width="25">
                <img alt="[Note]" src="images/note.png" />
              </td>
              <th align="left">Note</th>
            </tr>
            <tr>
              <td align="left" valign="top">
                <p>
        The sampling rate of the orchestra must be 44.1kHz. This is because 44.1kHz is the sampling rate at which the HRTFs were measured. In order to be used at a different rate, the HRTFs would need to be re-sampled at the desired rate.
      </p>
              </td>
            </tr>
          </table>
        </div>
      </div>
      <div class="refsect1">
        <a id="idp219542768"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the hrtfer opcode. It uses the file <a class="ulink" href="examples/hrtfer.csd" target="_top"><em class="citetitle">hrtfer.csd</em></a>,  <a class="ulink" href="examples/HRTFcompact" target="_top"><em class="citetitle">HRTFcompact</em></a>, and <a class="ulink" href="examples/beats.wav" target="_top"><em class="citetitle">beats.wav</em></a>.
      </p>
        <div class="example">
          <a id="idp219546288"></a>
          <p class="title">
            <strong>Example 1140. Example of the hrtfer opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
<span class="comment">; Audio out   Audio in    No messages</span>
-odac           -iadc     -d     <span class="comment">;;;RT audio I/O</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o hrtfer.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="comment">; Initialize the global variables.</span>
<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">kr</span> <span class="op">=</span> 4410
<span class="ohdr">ksmps</span> <span class="op">=</span> 10
<span class="ohdr">nchnls</span> <span class="op">=</span> 2

<span class="oblock">instr</span> 1
  kaz          <span class="opc">linseg</span> 0, p3, <span class="op">-</span>360  <span class="comment">; move the sound in circle</span>
  kel          <span class="opc">linseg</span> <span class="op">-</span>40, p3, 45  <span class="comment">; around the listener, changing</span>
                                    <span class="comment">; elevation as its turning</span>
  asrc         <span class="opc">soundin</span> "beats.wav"
  aleft,aright <span class="opc">hrtfer</span> asrc, kaz, kel, "HRTFcompact"
  aleftscale   <span class="op">=</span> aleft <span class="op">*</span> 200
  arightscale  <span class="op">=</span> aright <span class="op">*</span> 200

  <span class="opc">outs</span>         aleftscale, arightscale
<span class="oblock">endin</span>        


<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>

<span class="stamnt">i</span> 1 0 2
<span class="stamnt">e</span>


<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp219550576"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="hrtfmove.html" title="hrtfmove"><em class="citetitle">hrtfmove</em></a>,
      <a class="link" href="hrtfmove2.html" title="hrtfmove2"><em class="citetitle">hrtfmove2</em></a>,
      <a class="link" href="hrtfstat.html" title="hrtfstat"><em class="citetitle">hrtfstat</em></a>.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp219554576"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Authors: Eli Breder and David MacIntyre</td>
          </tr>
          <tr>
            <td>Montreal</td>
          </tr>
          <tr>
            <td>1996</td>
          </tr>
        </table>
        <p>
    </p>
        <p>Fixed the example thanks to a message from Istvan Varga.</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="clock.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="DeprecatedTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="ibetarand.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">clock </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> ibetarand</td>
        </tr>
      </table>
    </div>
  </body>
</html>
